import { hospital_detail,hospital_department } from "../../api/hospital_detail/index"
import { defineStore } from "pinia"
const useDetailStore = defineStore('Detail', {
  state: () => {
    return {
      hospitalInfo: '',
      hospitalDepartment:''
    }
  },
  // persist: {
  //   enabled: true // true 表示开启持久化保存
  // },
  actions: {
    // 获取医院信息
   async getHospitalDetail(hoscode:string) {
      let result = await hospital_detail(hoscode)
      if (result.code === 200) {
        // 医院详情信息放到全局
        this.hospitalInfo = result.data        
      }
    },
    // 获取科室信息
    async getHospitalDepartment(hoscode:string) {
      let result = await hospital_department(hoscode)
      if (result.code === 200) {
        // 医院详情信息放到全局
        this.hospitalDepartment = result.data   
        console.log(this.hospitalDepartment);
      }
    },
  },
  getters: {
    
  }
}) 
// 暴露仓库方法
export default useDetailStore